//
//  MinePage.m
//  收纳
//
//  Created by  on 2022/10/26.
//

#import "MinePage.h"
#import "MineCell.h"
#import "GoodsListViewController.h"
#import "ContainerManagerViewController.h"
#import "PrivateViewController.h"

@interface MinePage()
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSArray *titles;

@end
@implementation MinePage

- (void)awakeFromNib {
    [super awakeFromNib];
    self.titles = @[@"物品统计",@"容器管理",@"关于我们",@"隐私政策"];
    [self.tableView registerNib:[MineCell nib] forCellReuseIdentifier:[MineCell ID]];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.titles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MineCell *cell = [tableView dequeueReusableCellWithIdentifier:[MineCell ID]];
    cell.title.text = self.titles[indexPath.section];
    cell.input.hidden = YES;
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 14;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 14)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *title = self.titles[indexPath.section];
    if ([title isEqualToString:@"物品统计"]) {
        GoodsListViewController *vc = [GoodsListViewController new];
        [[self currentVC] push:vc :YES];
    }else if([title isEqualToString:@"容器管理"]){
        ContainerManagerViewController *vc = [ContainerManagerViewController new];
        vc.array = self.array;
        [[self currentVC] push:vc :YES];
    }else if([title isEqualToString:@"关于我们"]){
        
    }else if([title isEqualToString:@"隐私政策"]){
        PrivateViewController *vc = [PrivateViewController new];
        [[self currentVC] push:vc :YES];
    }
    
}
@end

